home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok33.lha
/
RemTabs
/
RemTabs.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
3KB
|
93 lines
(* -------------------------------------------------------------------------
:Program. RemTabs
:Author. Kai Bolay
:Address. Hoffmannstraße 168, 7250 Leonberg
:Phone. 07152/22135
:History. v1.0 Initial
:history. v1.1 Bug fixes
:Copyright. Freeware
:Language. Modula-2
:Translator. M2Amiga 3.2d
:Contents. Remove all Tabs from a Textfile and replace by Spaces
:Remark. Tab-Stops are every 8th column
------------------------------------------------------------------------- *)
MODULE RemTabs;
FROM Arts IMPORT DetectCtrlC;
FROM Arguments IMPORT NumArgs, GetArg;
FROM ASCII IMPORT ht, cr, lf;
FROM Terminal IMPORT WriteString, WriteLn;
FROM FileSystem IMPORT File, Lookup, Close, ReadChar, WriteChar, done;
CONST TabWidth = 8; (* change it if you want! *)
VAR OldFileName,
NewFileName : ARRAY [0..31] OF CHAR;
OldFile,
NewFile : File;
ProgName : ARRAY [0..100] OF CHAR;
Len : INTEGER;
PosInLine : CARDINAL;
ActChar : CHAR;
Start : BOOLEAN;
BEGIN
DetectCtrlC (FALSE);
GetArg (0, ProgName, Len);
WriteString ("Written 1989 by Kai Bolay / Version 1.1"); WriteLn;
IF NumArgs () # 2 THEN
WriteString ("Usage: "); WriteString (ProgName);
WriteString (" 'OldFile' 'NewFile'"); WriteLn;
WriteString (" OldFile: File with Tabs"); WriteLn;
WriteString (" NewFile: Output File without Tabs"); WriteLn;
ELSE
GetArg (1, OldFileName, Len);
GetArg (2, NewFileName, Len);
Lookup (OldFile, OldFileName, 1024, FALSE);
IF OldFile.res # done THEN
WriteString ("Can't open '"); WriteString (OldFileName);
WriteString ("'"); WriteLn;
ELSE
Lookup (NewFile, NewFileName, 1024, TRUE);
IF NewFile.res # done THEN
WriteString ("Can't create '"); WriteString (NewFileName);
WriteString ("'"); WriteLn;
ELSE
PosInLine := 1;
LOOP
ReadChar (OldFile, ActChar);
IF OldFile.res # done THEN
WriteString ("Error while reading!"); WriteLn;
EXIT;
END; (* IF *)
IF OldFile.eof = TRUE THEN EXIT; END;
IF ActChar = ht THEN
Start := TRUE;
WHILE (((PosInLine-1) MOD TabWidth) # 0) OR Start DO
WriteChar (NewFile, ' ');
INC (PosInLine);
IF NewFile.res # done THEN
WriteString ("Error while writing"); WriteLn;
EXIT;
END; (* IF *)
Start := FALSE; (* to avoid endless loop *)
END; (* WHILE *)
ELSE
WriteChar (NewFile, ActChar);
INC (PosInLine);
IF NewFile.res # done THEN
WriteString ("Error while writing!"); WriteLn;
EXIT;
END; (* IF *)
END; (* IF *)
IF (ActChar = lf) OR (ActChar = cr) THEN
PosInLine := 1;
END; (* IF *)
END; (* LOOP *)
Close (NewFile);
END; (* IF *)
Close (OldFile);
END; (* IF *)
END; (* IF *)
END RemTabs.